<!--回弹业务数据字典---回弹仪器设备管理---查看-->
<template>
  <div class="department" id="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group v-model="radio" size="small" @change="modelType($event)">
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
            <!-- #2b5a9d -->
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button type="primary" icon="el-icon-refresh" size="small" @click="yj_searchForm(getList)"></el-button>

            <el-button type="primary" icon="el-icon-search" size="small" v-if="yj_view" @click="editText(fId)">查看
            </el-button>
            <el-button type="primary" icon="el-icon-circle-plus-outline" size="small"
              v-if="getList.modelType == '0' && yj_add == true" @click="edit(0)">新增</el-button>
            <el-button type="primary" icon="el-icon-edit" size="small" v-if="getList.modelType == '0' && yj_edit == true"
              @click="edit(1)">编辑</el-button>
            <el-button type="primary" icon="el-icon-circle-check" size="small"
              v-if="getList.modelType == '0' && yj_submit == true" @click="SubmitText(fId)">提交</el-button>
            <el-button type="primary" icon="el-icon-delete" size="small"
              v-if="getList.modelType == '0' && yj_delete == true" @click="rowDelete(fId)">删除</el-button>
          </div>
        </div>
      </div>

      <!-- 表格 -->
      <div class="text_table">
        <tableData :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'" :config="table_config"
          :dataList="tableData" :loading="loading" @selection-change="selectionChange" @sort-change="sortChange"
          @click-change="rowChange" @openDialog="yj_viewForm" :page="getList.page" :pageSize="getList.pageSize" />
        <pagination v-if="navigatepageNums > 1" :info="queryCriteriaData" :treelength="treelength"
          :total="queryCriteriaData.total" :pageNum.sync="getList.page" :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)" />
      </div>

      <!--弹框 查看 -->
      <div class="Control-1 mechanism_dialogS">
        <el-dialog title="查看仪器设备信息" v-dialogDrag :visible.sync="dialogTableVisible" v-loading="loadingDialog"
          element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '550px' }">
            <el-form :model="formData" ref="formData">
              <div class="tableRow">
                <el-form-item label="建设项目简称" prop="fProjectname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fProjectname" autocomplete="off" placeholder="请输入" disabled></el-input>
                </el-form-item>
                <el-form-item label="施工标段简称" prop="fCompanyname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fCompanyname" autocomplete="off" placeholder="请输入" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="外检设备类型" prop="fUseplace" :label-width="formLabelWidth">
                  <el-input v-model="formData.fUseplace" autocomplete="off" disabled></el-input>
                </el-form-item>
                <el-form-item label="设备名称" prop="fEqptname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptname" autocomplete="off" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="设备编号" prop="fEqptno" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptno" autocomplete="off" disabled></el-input>
                </el-form-item>
                <el-form-item label="规格型号" prop="fEqptspecs" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptspecs" autocomplete="off" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="制造厂家" prop="fFactoryname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fFactoryname" autocomplete="off" disabled></el-input>
                </el-form-item>
                <el-form-item label="生产编号" prop="fCertificationno" :label-width="formLabelWidth">
                  <el-input v-model="formData.fCertificationno" autocomplete="off" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="生产日期" prop="fOutdates" :label-width="formLabelWidth">
                  <el-input v-model="formData.fOutdates" autocomplete="off" disabled></el-input>
                </el-form-item>
                <el-form-item label="保管人" prop="fOperusername" :label-width="formLabelWidth">
                  <el-input v-model="formData.fOperusername" autocomplete="off" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow SelectTime">
                <el-form-item label="资料附件" prop="fSourcefile" :label-width="formLabelWidth" class="enclosure"
                  style="height: 100%">
                  <el-input v-if="false" v-model="formData.fSourcefile" autocomplete="off">
                  </el-input>
                  <div style="
                          height: 25px;
                          line-height: 25px;
                          width: 100%;
                          display: flex;
                          border: 1px solid #d1d7e2;
                          border-radius: 5px;
                          margin: 8px 0 2px 0;
                        ">
                    <div v-for="(v, i) in fSourcefileList" :key="i" style="margin: 0 3px" v-viewer>
                      <img style="max-width: 100%; max-height: 100%" :src="v.url" />
                    <!-- <img
                        src="@/assets/img/enclosure/imgs.png"
                        alt=""
                        style="height: 90%"
                                          /> -->
                    </div>
                  </div>
                </el-form-item>
              </div>
              <div class="tableRow" style="margin-top: 10px">
                <el-form-item label="备注" prop="fNote" :label-width="formLabelWidth">
                  <el-input v-model="formData.fNote" type="textarea" :rows="4" placeholder="请输入内容" autocomplete="off"
                    disabled></el-input>
                </el-form-item>
              </div>
            </el-form>
          </div>
        </el-dialog>
      </div>
      <!--弹框 新增/编辑 -->
      <div class="Control-1 mechanism_dialogS">
        <el-dialog :title="dialogText" v-dialogDrag :visible.sync="dialogTableVisibleText" v-loading="loadingDialogText"
          element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '550px' }">
            <el-form :model="formData" :rules="rules" ref="formData">
              <div class="tableRow">
                <el-form-item label="建设项目简称" prop="fProjectname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fProjectname" autocomplete="off" placeholder="请输入" disabled></el-input>
                </el-form-item>
                <el-form-item label="施工标段简称" prop="fCompanyname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fCompanyname" autocomplete="off" placeholder="请输入" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="外检设备类型" prop="fUseplace" :label-width="formLabelWidth">
                  <el-select v-model="formData.fUseplace" placeholder="请选择">
                    <el-option v-for="(v, i) in departmentList" :key="i" :label="v.text" :value="v.text">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="设备名称" prop="fEqptname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptname" autocomplete="off"></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="设备编号" prop="fEqptno" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptno" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="规格型号" prop="fEqptspecs" :label-width="formLabelWidth">
                  <el-input v-model="formData.fEqptspecs" autocomplete="off"></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="制造厂家" prop="fFactoryname" :label-width="formLabelWidth">
                  <el-input v-model="formData.fFactoryname" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="生产编号" prop="fCertificationno" :label-width="formLabelWidth">
                  <el-input v-model="formData.fCertificationno" autocomplete="off"></el-input>
                </el-form-item>
              </div>
              <div class="tableRow SelectTime">
                <el-form-item label="生产日期" prop="fOutdates" :label-width="formLabelWidth">
                  <el-date-picker v-model="formData.fOutdates" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
                    autocomplete="off">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="保管人" prop="fOperusername" :label-width="formLabelWidth">
                  <el-input v-model="formData.fOperusername" autocomplete="off" disabled></el-input>
                </el-form-item>
              </div>
              <div class="tableRow SelectTime">
                <el-form-item label="资料附件" prop="fSourcefile" :label-width="formLabelWidth" class="enclosure"
                  style="height: 100%">
                  <el-input v-if="false" v-model="formData.fSourcefile" autocomplete="off">
                  </el-input>

                  <div style="
                          height: 25px;
                          line-height: 25px;
                          width: 90%;
                          display: flex;
                          border: 1px solid #d1d7e2;
                          border-radius: 5px;
                          margin: 8px 0 2px 0;
                        " v-if="dialogText == '编辑'">
                    <div v-for="(v, i) in fSourcefileList" :key="i" style="margin: 0 3px" v-viewer>
                      <img style="max-width: 100%; max-height: 100%" :src="v.url" />
                    </div>
                  </div>
                  <!-- 新增 -->
                  <div style="
                          height: 25px;
                          line-height: 25px;
                          width: 90%;
                          display: flex;
                          border: 1px solid #d1d7e2;
                          border-radius: 5px;
                          margin: 8px 0 2px 0;
                        " v-else-if="dialogText == '新增'">
                    <div v-for="(v, i) in fSourcefileList" :key="i" style="margin: 0 3px" @click="operation()">
                      <img :src="v.url" alt="" style="height: 90%" />
                    </div>
                  </div>
                  <el-button type="primary" icon="el-icon-search" size="small" @click="operation()"
                    style="margin: 8px 0 2px 3px">操作</el-button>
                </el-form-item>
              </div>
              <div class="tableRow" style="margin-top: 10px">
                <el-form-item label="备注" prop="fNote" :label-width="formLabelWidth">
                  <el-input v-model="formData.fNote" type="textarea" rows="4" placeholder="请输入内容" autocomplete="off">
                  </el-input>
                </el-form-item>
              </div>
              <el-form-item class="newlyAdded_btn">
                <el-button type="primary" @click="submitForm('formData')">保存</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-dialog>
      </div>
      <!-- 上传附件  -->
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog title="上传附件" v-dialogDrag class="uploadWidth" id="uploadWidth" :visible.sync="dialogTableVisibleTexts"
          v-loading="loadingDialogTexts" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: dialogHeights }">
            <el-upload action="action" ref="upload" list-type="picture-card" :auto-upload="false"
              :file-list="fSourcefileList" :on-change="handleChange"
              accept=".jpg, .jpeg, .png, .gif, .bmp, .JPG, .JPEG, .PBG, .GIF, .BMP">
              <i slot="default" class="el-icon-plus"></i>
              <div style="width: 100%; height: 100%; text-align: center" slot="file" slot-scope="{ file }">
                <div style="
                        width: 100%;
                        height: 100%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                      " class="images" v-viewer>
                  <img style="max-width: 100%; max-height: 100%" :src="file.url" />
                </div>
                <span class="el-upload-list__item-actions">
                  <span title="预览图片" class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span title="删除图片" class="el-upload-list__item-delete" @click="handleRemove(file)">
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload(enclosureImg)">保存</el-button>
                <!-- <el-button type="warning" @click="resetForm()">关闭</el-button> -->
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getMangEquipmentPageList,
  getMangEquipmentByFid,
  addMangEquipment,
  delMangEquipment,
  submitMangEquipment,
  upload,
} from "@/api/request.js";
import TableData from "@/components/public/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
export default {
  inject: ["reload"],
  name: "Home",
  data() {
    return {
      name: "instrumentText",
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      // 分页

      yj_view: null,
      yj_add: null,
      yj_edit: null,
      yj_delete: null,
      yj_submit: null,
      // 上传附件
      disabled: false,
      dialogTableVisibleTexts: false,
      loadingDialogTexts: false,
      enclosureImg: {},
      timestamp: null,
      attachmentDetails: [],
      imgsFId: {
        fId: null, //文件id
      },
      imgsRemoveList: null,
      imgList: [],
      recordfilesList: [],

      // 上传附件
      departmentList: [
        { text: "混凝土回弹检测仪器设备" },
        { text: "钢筋保护层厚度检测设备" },
      ], //外检设备类型
      radio: "待办",
      dialogHeight: "",
      dialogHeights: "240px",
      fId: null, //当前数据fId
      loading: false,
      fDepartmentid: "", //当前行部门id
      dialogFormVisible: false,
      userInfo: {}, //登录用户
      // 列表
      getList: {
        modelType: "0", // 0代办 1已办
        fCompanyid: null, //机构id
        fUserid: null, //当前登录用户id
        sublevel: null, //查看下级  1是0否
        keyWord: null, //设备名称模糊查询字段
        keyType: null, //设备类型
        page: 1, //页码
        pageSize: 20, //每页条数
      },
      table_config: {
        // 列表配置项
        imgKeyWord: "url",
        fileKeyWord: "url",
        fileName: "fFileName",
        dialogHeight: "",
        thead: [
          {
            label: "建设项目简称",
            prop: "fProjectname",
            minWidth: "200px",
            align: "left",
          },
          {
            label: "施工标段简称",
            prop: "fCompanyname",
            minWidth: "200px",
            align: "left",
          },
          {
            label: "外检设备类型",
            prop: "fUseplace",
            minWidth: "200px",
            align: "left",
          },
          {
            label: "设备编码",
            prop: "fEqptno",
            minWidth: "120px",
            align: "left",
          },
          {
            label: "设备名称",
            prop: "fEqptname",
            minWidth: "120px",
            align: "left",
          },
          {
            label: "规格型号",
            prop: "fEqptspecs",
            minWidth: "120px",
            align: "left",
          },

          {
            label: "制造厂家",
            prop: "fFactoryname",
            minWidth: "200px",
            align: "center",
          },
          {
            label: "生产编号",
            prop: "fCertificationno",
            minWidth: "100px",
            align: "center",
          },
          {
            label: "生产日期",
            prop: "fOutdates",
            minWidth: "100px",
            align: "center",
          },
          {
            label: "备注",
            prop: "fNote",
            minWidth: "100px",
            align: "center",
          },
          {
            label: "信息状态",
            prop: "fStatus",
            minWidth: "100px",
            align: "center",
          },
        ],
        isCheckBox: false,
        isIndex: true,
        isOperation: true,
        // 表格操作列
        operation: {
          label: "操作",
          width: "100",
          detail: true,
          cols: [],
        },
      },

      // 新增/编辑
      dialogText: "",
      dialogTableVisibleText: false,
      loadingDialogText: false,
      rules: {
        fProjectname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fCompanyname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fUseplace: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fEqptname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fEqptno: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fEqptspecs: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fOutdates: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fOperusername: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
      },
      // 查看
      loadingDialog: false,
      dialogTableVisible: false,
      formData: {
        fId: null, //主键id
        fProjectid: null, //建设项目id
        fProjectname: null, //建设项目简称
        fCompanyid: null, //施工标段id
        fCompanyname: null, //施工标段简称
        fUseplace: null, //外检设备类型
        fEqptno: null, //设备编号
        fEqptname: null, //设备名称
        fEqptspecs: null, //规格型号
        fFactoryname: null, //制造厂家
        fCertificationno: null, //生产编号
        fOutdates: null, //生产日期
        fOperuserid: null, //保管人id
        fOperusername: null, //保管人
        fSourcefile: null, //资料附件
        fNote: null, //备注
        userId: null, //当前登录用户id
        userName: null, //当前登录用户姓名
        recordfiles: [], //删除文件id集合--修改时传
      },
      fSourcefileList: [],
      row: null,
      formLabelWidth: "82px",
      tableData: [], //表格数据列表
      dialogVisible: false,
    };
  },
  components: {
    TableData, //主页面列表
    Pagination, //分页
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("monitorBack-userInfo"));
    this.getList.fUserid = this.userInfo.userId;
    this.getList.fCompanyid = this.userInfo.companyId;
  },
  mounted() {
    this.table_config.operation.cols = [
      {
        label: "查看",
        type: "primary",
        handleRow: this.handleRow,
      },
    ];
    this.getHeight();
    this.yj_searchForm(this.getList);
    this.btnRole(this.name);
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("monitorBack-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        this.yj_view = btnStr.includes("yj_look");
        this.yj_add = btnStr.includes("yj_add");
        this.yj_edit = btnStr.includes("yj_edit");
        this.yj_delete = btnStr.includes("yj_delete");
        this.yj_submit = btnStr.includes("yj_submit");
      } else {
        this.yj_view = true;
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        this.yj_submit = true;
      }
    },
    // 上传附件
    // 移除
    handleRemove(file) {
      this.$refs.upload.handleRemove(file);
      for (let index = 0; index < this.fSourcefileList.length; index++) {
        console.log(file.uid, this.fSourcefileList[index].uid);
        if (file.uid == this.fSourcefileList[index].uid) {
          console.log(2);

          // this.imgsFId.fId = this.fPhotofilelist[index].atta.fId;

          if (this.fSourcefileList[index].atta == undefined) {
            console.log(
              this.fSourcefileList[index].atta,
              this.fSourcefileList[index].fId
            );
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].fId,
            });
          } else {
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].atta.fId,
            });
          }
          this.fSourcefileList.splice(index, 1);
        }
      }
    },
    // 预览
    handlePictureCardPreview(file) {
      for (let i = 0; i < this.$el.querySelectorAll(".images").length; i++) {
        if (
          file.url ===
          this.$el.querySelectorAll(".images")[i].getElementsByTagName("img")[0]
            .src
        ) {
          const viewer = this.$el.querySelectorAll(".images")[i].$viewer;
          viewer.show();
          break;
        }
      }
    },
    // 操作按钮
    operation() {
      this.dialogTableVisibleTexts = true;
    },

    // 上传照片
    handleChange(res) {
      this.attachmentDetails.push(res);
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里
      this.enclosureImg.append("folderid", this.timestamp); //将file属性添加到formData里
      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里

      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;

        this.fSourcefileList.push(i[0]);
      });
      console.log(this.fSourcefileList);
    },
    // 保存上传图片
    submitUpload() {
      this.dialogTableVisibleTexts = false;
    },
    // 上传附件
    modelType(e) {
      this.fId = "";
      this.row = "";
      if (e == "待办") {
        this.getList.modelType = "0";
      } else {
        this.getList.modelType = "1";
      }
      this.yj_searchForm(this.getList);
    },
    // 获取列表数据
    yj_searchForm(id) {
      this.loading = true;
      getMangEquipmentPageList(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.mangEquipmentList.list;
            that.queryCriteriaData = res.data.mangEquipmentList;
            that.navigatepageNums =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("列表");
          this.loading = false;
        });
    },

    // 查看
    editText(id) {
      if (id != "" && id != null) {
        this.dialogTableVisible = true;
        this.loadingDialog = false;
        getMangEquipmentByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              var that = this;
              that.loadingDialog = false;
              that.dialogTableVisible = true;
              that.formData = res.data.lrMangEquipment;
              that.fSourcefileList = res.data.fSourcefileList;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingDialog = false;
            }
          })
          .catch(() => {
            console.log("查看");
            this.loadingDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },

    // 新增/编辑
    edit(num) {
      this.formData = {
        fId: null, //主键id
        fProjectid: null, //建设项目id
        fProjectname: null, //建设项目简称
        fCompanyid: null, //施工标段id
        fCompanyname: null, //施工标段简称
        fUseplace: null, //外检设备类型
        fEqptno: null, //设备编号
        fEqptname: null, //设备名称
        fEqptspecs: null, //规格型号
        fFactoryname: null, //制造厂家
        fCertificationno: null, //生产编号
        fOutdates: null, //生产日期
        fOperuserid: null, //保管人id
        fOperusername: null, //保管人
        fSourcefile: null, //资料附件
        fNote: null, //备注
        userId: null, //当前登录用户id
        userName: null, //当前登录用户姓名
        recordfiles: [], //删除文件id集合--修改时传
      };
      if (num == 0) {
        // 新增
        this.fSourcefileList = [];
        this.timestamp = "EQUIP" + Date.parse(new Date());
        this.formData.fSourcefile = this.timestamp;
        this.formData.userId = this.userInfo.userId;
        this.formData.userName = this.userInfo.realName;
        this.formData.fProjectid = this.userInfo.projectId;
        this.formData.fProjectname = this.userInfo.projectName;
        this.formData.fCompanyid = this.userInfo.companyId;
        this.formData.fCompanyname = this.userInfo.companyName;
        this.formData.fOperuserid = this.userInfo.userId;
        this.formData.fOperusername = this.userInfo.realName;
        this.dialogText = "新增";
        this.dialogTableVisibleText = true;
      } else {
        // 编辑
        if (this.fId != null && this.fId != "") {
          this.dialogText = "编辑";
          this.dialogTableVisibleText = true;
          this.loadingDialogText = true;
          getMangEquipmentByFid({ fId: this.fId })
            .then((res) => {
              if (res.errcode == 0) {
                console.log("编辑", res);
                var that = this;
                that.loadingDialogText = false;
                that.dialogTableVisibleText = true;
                this.timestamp = res.data.lrMangEquipment.fSourcefile;
                that.formData = res.data.lrMangEquipment;
                that.fSourcefileList = res.data.fSourcefileList;
                this.formData.recordfiles = [];
              } else {
                this.$message.error("编辑", res.msg);
                this.loadingDialogText = false;
              }
            })
            .catch(() => {
              console.log("编辑失败");
              this.loadingDialogText = false;
            });
        } else {
          return this.$message.error("请先选择需要编辑的数据");
        }
      }
    },
    // 保存
    submitForm(formName) {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.loadingDialogText = true;
          addMangEquipment(this.formData)
            .then((res) => {
              if (res.errcode == 0) {
                this.yj_searchForm(this.getList);
                this.loadingDialogText = false;
                this.dialogTableVisibleText = false;
                this.$message.success("保存成功");
                this.$refs[formName].resetFields();
              } else {
                this.$message.error("保存失败", res.msg);
                this.loadingDialogText = false;
              }
            })
            .catch(() => {
              console.log("保存失败");
              this.loadingDialogText = false;
            });
        } else {
          this.$message.error("请填写必填项");
        }
      });
    },
    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        this.$confirm("是否继续提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            submitMangEquipment({
              fId: id,
              userId: this.userInfo.userId,
              userName: this.userInfo.realName,
            })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.yj_searchForm(this.getList);
                  this.$message.success("提交成功");
                } else {
                  this.$message.error("提交失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("提交失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消提交");
          });
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },
    // 删除
    rowDelete(id) {
      if (id != "" && id != null) {
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            delMangEquipment({ fId: id })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.yj_searchForm(this.getList);
                  this.$message.success("删除成功");
                } else {
                  this.$message.error("删除失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("删除失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消删除");
          });
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },

    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      this.dialogHeight = h * 0.36 + "px";
    },
    // 点击查看
    yj_viewForm(row) {
      this.row = row;
      this.fId = row.fId;
      this.editText(this.fId);
    },
    // 点击当前
    rowChange(val) {
      this.row = val;
      this.fId = val.fId;
    },
    // 多选方法
    selectionChange() { },
    // 排序方法
    sortChange() { },
  },
};
</script>

<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.pageFlagText {
  color: #171a1d;
  font-size: 16px;
}

#uploadWidth /deep/.el-dialog {
  width: 47% !important;
}
</style>